import React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux'
import { mPacs } from '../../store/actions';

class _ImageView extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            studyId: this.props.params.id,
            viewUrl:''
        }
    }
    componentWillMount(){
        const _this = this;
        _this.props.dispatch(mPacs(this.props.params.id,function(url){
            _this.setState({
                viewUrl:url
            })
        }))
    }
    render(){
        if(this.state.viewUrl == ''){
            return (<div>loading...</div>)
        }else{

            return(
                <div id="image-view">
                    <iframe
                        style={{width:'100%',height:'300px',border:'none'}}
                        src={this.state.viewUrl}>
                    </iframe>
                </div>
            )
        }

    }
}
const ImageView = connect((state)=>{
    const {user} = state.rootReducer;
    return {user}
})(_ImageView);
export default ImageView;